/*
 * FlowLayout
 * Copyright (C) 2004-2008 Trolltech ASA. All rights reserved.
 * Modified by Philip Pronin, 2008
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef FLOWLAYOUT_H
#define FLOWLAYOUT_H

#include <QLayout>
#include <QRect>
#include <QWidgetItem>

class FlowLayout: public QLayout {
public:
	FlowLayout(QWidget* parent, int margin = 0, int spacing = -1);
	FlowLayout(int spacing = -1);
	virtual ~FlowLayout();

	void addItem(QLayoutItem* item);
	Qt::Orientations expandingDirections() const;
	bool hasHeightForWidth() const;
	int heightForWidth(int) const;
	int count() const;
	QLayoutItem* itemAt(int index) const;
	QSize minimumSize() const;
	void setGeometry(const QRect &rect);
	QSize sizeHint() const;
	QLayoutItem* takeAt(int index);

private:
	int doLayout(const QRect &rect, bool testOnly) const;
	
private:
	QList<QLayoutItem*> itemList;
	int cachedWidth, cachedHeight;
};

#endif
